package com.dmgis.hndz.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil;
import com.dmgis.hndz.mapper.SMSTemplateManagementMapper;
import com.dmgis.hndz.pojo.SMSTemplateManagement;
import com.dmgis.hndz.service.SMSTemplateManagementService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author pengdongdong
 * @description public
 * @date 2024-11-05
 */
@Service
public class SMSTemplateManagementServiceImpl implements SMSTemplateManagementService {

    @Resource
    private SMSTemplateManagementMapper sMSTemplateManagementMapper;

    /**
     * 新增
     *
     * @author pengdongdong
     * @date 2024/11/11
     **/
    public int insertSMSTemplateManagement(SMSTemplateManagement sMSTemplateManagement) {
        sMSTemplateManagement.setId(IdUtil.simpleUUID());
        sMSTemplateManagement.setCreateTime(new Date());
        return sMSTemplateManagementMapper.insertSMSTemplateManagement(sMSTemplateManagement);
    }

    /**
     * 刪除
     *
     * @author pengdongdong
     * @date 2024/11/11
     **/
    public int deleteSMSTemplateManagement(String ids) {
        return sMSTemplateManagementMapper.deleteSMSTemplateManagement(Convert.toStrArray(ids));
    }

    /**
     * 更新
     *
     * @author pengdongdong
     * @date 2024/11/11
     **/
    public int updateSMSTemplateManagement(SMSTemplateManagement sMSTemplateManagement) {
        sMSTemplateManagement.setUpdateTime(new Date());
        return sMSTemplateManagementMapper.updateSMSTemplateManagement(sMSTemplateManagement);
    }

    /**
     * 查询 根据主键 id 查询
     *
     * @author pengdongdong
     * @date 2024/11/11
     **/
    public SMSTemplateManagement selectSMSTemplateManagementById(String id) {
        return sMSTemplateManagementMapper.selectSMSTemplateManagementById(id);
    }

    /**
     * 查询 分页查询
     *
     * @author pengdongdong
     * @date 2024/11/11
     **/
    public PageInfo<SMSTemplateManagement> selectSMSTemplateManagementList(Integer pageNum, Integer pageSize, SMSTemplateManagement sMSTemplateManagement) {
        if (pageNum != null && pageSize != null) {
            PageHelper.startPage(pageNum, pageSize);
        }
        return new PageInfo<>(sMSTemplateManagementMapper.selectSMSTemplateManagementList(sMSTemplateManagement));
    }

}